﻿using System.Diagnostics;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;
namespace MvcApplication.CommonWebApi
{
    public class CommonController : ApiController
    {
        // /Api/Common?commonId=
        // 在启动项中，可能需要nuget安装 Microsoft.AspNet.WebApi.Core
        public HttpResponseMessage Get(string commonId)
        {
            //var sw = new Stopwatch();
            //sw.Start();
            CommonWebApiService service = new CommonWebApiService();
            var result =  service.LoadCommonAPi(commonId);

            var response = this.Request.CreateResponse(HttpStatusCode.OK);
            response.Content = new StringContent(result, Encoding.UTF8, "application/json");
            return response;
            //sw.Stop();
            //var cost = sw.ElapsedMilliseconds;
        }
    }
}
